package com.cloud.provider.service;

import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import com.cloud.provider.entity.BaseUser;
import com.cloud.provider.service.BaseUserService.BaseUserServiceFallback;

@FeignClient(name = "Base-Service-Provider", fallback = BaseUserServiceFallback.class)
public interface BaseUserService {

	@RequestMapping(value = "/getBaseUser/{id}", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
	BaseUser getBaseUser(@PathVariable("id") Integer id);

	@Component
	static class BaseUserServiceFallback implements BaseUserService {
		@Override
		public BaseUser getBaseUser(Integer id) {
			BaseUser user = new BaseUser();
			user.setAddress("this is Hystrix+Feign error msg!");
			return user;
		}

	}
}
